#!/usr/bin/env python
# -*- coding: utf-8 -*-

# #portugues@ScoutLink 2006 JOTI Bot (slbot)
# Copyright (c) 2006, ScoutLink #portugues team
# This source is released under the New BSD License. See the LICENSE file for further
# information.

# $Author: fmobus $
# $Date: 2006-09-20 19:26:49 +0000 (Wed, 20 Sep 2006) $ 

__version__ = "$Revision: 23 $"
# $Source$

import twisted.internet

import slbot

class SLBotFactory(twisted.internet.protocol.ClientFactory):
    protocol = slbot.SLBot

    def __init__(self, config):
        self.config = config

    def clientConnectionLost(self, connector, reason):
        connector.connect()

    def clientConnectionFailed(self, connector, reason):
        print "Connection failed:", reason
        twisted.internet.reactor.stop()

    def buildProtocol(self, addr):
        p = self.protocol(self.config)
        p.factory = self
        return p
